<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/2/11
 * Time: 11:00
 */

namespace Kordar\Tree;

/**
 * Class Group
 * @package yak\libs\tree
 */
class Group
{
    public function minHeapArr($data)
    {
        $groups = [];
        foreach ($data as $val) {
            $key = $val['pid'];
            if (!isset($groups[$key])) {
                $groups[$key] = new GroupHeap();
            }
            $groups[$key]->insert(new BinaryNode($val));
        }
        return array_map(function ($it) {
            return iterator_to_array($it);
        }, $groups);
    }
}